package cn.it.sqlSession;


import cn.it.config.XMLConfigBuilder;
import cn.it.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream inputStream) throws PropertyVetoException, DocumentException {

        // 读取解析配置文件
        XMLConfigBuilder builder = new XMLConfigBuilder();
        Configuration configuration = builder.pareConfig(inputStream);

        // 创建返回sqlSessionFactory对象
        return new DefaultSqlSessionFactory(configuration);
    }

}
